package org.dtrd.modules.record.entity.bean;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.dtrd.common.util.DateUtils;
import org.dtrd.config.system.Constant;
import org.dtrd.modules.record.entity.po.DtrdEntRdSigninSportRecord;

import java.util.Date;

/**
 * @Author QR
 * @Date 2021/11/3 10:38 AM
 */
@ApiModel("运动记录数据对象")
@Data
public class SportBean {

    @ApiModelProperty("记录id")
    private Integer dataId;

    @ApiModelProperty("患者id")
    private Integer patientId;

    @ApiModelProperty("记录时间")
    private String recordTime;

    @ApiModelProperty("运动步数")
    private Integer sportRecordStep;

    @ApiModelProperty("运动类型 1-快走,2-慢走等")
    private Integer sportRecordSteptype;

    @ApiModelProperty("有氧运动类型名称")
    private String sportRecordStepTypeName;

    @ApiModelProperty("力量运动描述")
    private String sportRecordPowerDescribe;

    @ApiModelProperty("运动备注")
    private String sportRecordRemark;

    @ApiModelProperty("运动图片")
    private String recordPhoto;

    public SportBean(){}

    public SportBean(Integer patientId, Date date, Integer type, String photo){
        this.patientId = patientId;
        this.recordTime = DateUtils.formatDate(date, DateUtils.datetimeFormat.get().toPattern());
        this.sportRecordSteptype = type;
        this.recordPhoto = photo;
    }

    public SportBean parseFromPo(DtrdEntRdSigninSportRecord po){
        dataId = po.getDataId();
        patientId = po.getPatientId();
        recordTime = DateUtils.formatDate(po.getRecordTime(), DateUtils.date_sdf.get().toPattern());
        sportRecordStep = po.getSportRecordStep();
        sportRecordSteptype = po.getSportRecordSteptype();
        // 取消名称处理 改为外部查询操作 肖 2022-06-13 11:46:59
//        if (sportRecordSteptype != null) {
//            Constant.SportRecordSteptype sport = Constant.SportRecordSteptype.valueOf(this.sportRecordSteptype);
//            assert sport != null;
//            sportRecordStepTypeName = sport.getName();
//        }
        sportRecordPowerDescribe = po.getSportRecordPowerDescribe();
        sportRecordRemark = po.getSportRecordRemark();
        recordPhoto = po.getRecordPhoto();
        return this;
    }
}
